﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections;
using System.Net.Http;

namespace ConsoleApp.Classex
{
    public static class HttpRequestMessageEx
    {
        /// <summary>
        /// 获得请求参数
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static Dictionary<string, string> QueryParams(this HttpRequestMessage request)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            foreach (var item in request.GetQueryNameValuePairs())
            {
                if (!dic.ContainsKey(item.Key))
                {
                    dic.Add(item.Key, item.Value);
                }
            }
            return dic;
        }
    }
}